[mirrors]
http://ftp.debian.org/debian/pool/main/c/ca-certificates/ca-certificates_20141019.tar.xz

[main]
filesize=289092
sha512=5b0e8fb917f5642a5a2b4fde46a706db0c652ff3fb31a5053d9123a5b670b50c6e3cf2496915cc01c613dcbe964d6432f393c12d8a697baedfad58f9d13e568b
tardir=ca-certificates-20141019

[deps]
openssl

[deps.host]
openssl

[build]
$HOSTCC "$K"/c_rehash.c -o c_rehash -lssl -lcrypto
export PATH=$PWD:"$PATH"
mkdir -p "$butch_install_dir""$butch_prefix"/share/ca-certificates/mozilla
patch -p1 < "$K"/ca-certificates.patch
cp "$K"/certdata2pem.c mozilla/
cat << EOF > mozilla/Makefile
all: a.out
	./a.out
a.out:
	\$(HOSTCC) -Wall -Wextra -O0 -g certdata2pem.c
clean:
	-rm -f *.crt
install:
	for p in *.crt; do \
	 install -D -m 644 \$\$p \$(CERTSDIR)/\$\$p ; \
	done
EOF
make
make DESTDIR="$butch_install_dir" install

mkdir -p "$butch_install_dir/etc/ssl/certs"

( cd "$butch_install_dir/share/ca-certificates/"
  find . -name '*.crt' | sort | cut -b3- > "$butch_install_dir/etc/ca-certificates.conf" )

cp sbin/update-ca-certificates .
sed -e 's#=/etc/#=${DESTDIR}/etc/#' -i update-ca-certificates
sed -e 's#=/share/#=${DESTDIR}/share/#' -i update-ca-certificates
sed -e 's#=/local/#=${DESTDIR}/local/#' -i update-ca-certificates

DESTDIR="$butch_install_dir" sh ./update-ca-certificates --fresh

